<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Cadastro de Usuários</title>
</h:head>
<h:body>
	<h1>Cadastro de Usuários</h1>
	<h:form id="cadastro">
		<h:messages />
		<!-- 
		<h:inputHidden value="#{usuarioBean.usuario.codigo}" />
		 -->

		<h:panelGrid columns="2" style="border: 1px solid red;">
			<!-- NOME DO NOIVO(A) -->
			<h:outputLabel value="Nome Noivo(a):" for="nomenoivo" />
			<h:inputText id="nomenoivo" label="Nome Noivo(a)" value="#{usuarioBean.usuario.nome}" size="30" 
						maxlength="30" required="true" requiredMessage="Você não tem nome?">
				<f:validateLength minimum="5" maximum="30" />
			</h:inputText>

			<!-- E-MAIL DO NOIVO(A) -->
			<h:outputLabel value="E-Mail Noivo(a):" for="emailnoivo" />
			<h:panelGroup>
				<h:inputText id="emailnoivo" label="E-Mail Noivo(a)" value="#{usuarioBean.usuario.email}" size="50" 
							maxlength="50" required="true" requiredMessage="e-mail inválido">
					<f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
				</h:inputText>
				<h:message for="emailnoivo" />
			</h:panelGroup>

			<!-- NOME DA NOIVA(O) -->
			<h:outputLabel value="Nome Noiva(o):" for="nomenoiva" />
			<h:inputText id="nomenoiva" label="Nome Noiva(a)" value="#{usuarioBean.usuario.nomeConjuge}" size="30" 
						maxlength="30" required="true" requiredMessage="Seu conjuge não tem nome?">
				<f:validateLength minimum="5" maximum="30" />
			</h:inputText>
			
			<!-- E-MAIL DA NOIVA(O) -->
			<h:outputLabel value="E-Mail Noiva(o):" for="emailnoiva" />
			<h:panelGroup>
				<h:inputText id="emailnoiva" label="E-Mail Noiva(o)" value="#{usuarioBean.usuario.emailConjuge}" size="50" 
							maxlength="50" required="true" requiredMessage="e-mail inválido">
					<f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
				</h:inputText>
				<h:message for="emailnoiva" />
			</h:panelGroup>
			
			<!-- NOME DO CASAL -->
			<h:outputLabel value="Nome do casal:" for="nomecasal" />
			<h:inputText id="nomecasal" label="Nome do casal" value="#{usuarioBean.usuario.nomeCasal}" size="30"
						maxlength="30" required="true" requiredMessage="Informe nome para o casal">
				<f:validateLength minimum="10" maximum="30" />
			</h:inputText>
			
			<h:outputLabel value="Data Casamento" for="data" />
			<h:inputText id="data" label="Data Casamento" value="#{usuarioBean.usuario.dataCasamento.time}" size="10" 
						maxlength="10" required="true">
				<f:convertDateTime type="date" dateStyle="medium" />
			</h:inputText>
			
			<h:outputLabel value="Login:" for="login" />
			<h:inputText id="login" label="Login" value="#{usuarioBean.usuario.login}" size="15" 
						maxlength="15" required="true" 
						validatorMessage="Login deve ter no mínimo 5 e no máximo 15 caracteres e só pode ter os símbolos '.' e '_'.">
				<f:validateRegex pattern="([a-z]|[0-9]|[.]|[_]){5,15}" />
			</h:inputText>
			
			<h:outputLabel value="Senha:" for="senha" />
			<h:inputSecret id="senha" label="Senha" value="#{usuarioBean.usuario.senha}" size="10" 
						maxlength="10" required="true" redisplay="true"/>
						
			<h:outputLabel value="Confirmar Senha:" for="confirmarsenha" />
			<h:inputSecret id="confirmarsenha" label="Confirmar Senha" value="#{usuarioBean.confirmarSenha}"
						size="10" maxlength="10" required="true" redisplay="true" />
		</h:panelGrid>
		
		<h:commandButton action="#{usuarioBean.salvar}" value="Salvar"/>
	</h:form>
</h:body>
</html>